﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using LongNet.Util;
using LongNet.Util.SqlServer;
namespace LongNet.Web.Controllers
{
    /*
     *http://localhost:7408/CodeProduce/index 显示页面
     *
     */
    public class CodeProduceController : Controller
    {
        //
        // GET: /CodeProduce/

        public ActionResult Index()
        {
            return View("ConvertAll");
        }

        public ActionResult GetConnectionString()
        {
            string conString = HttpUtil.GetAppSettings("LongNet.ConnectionString", false, false);
            return Json(new { con = conString });
        }

        public ActionResult CreateMode(string strNameSpace)
        {

            List<string> result = new List<string>();
            try
            {
               result= CodeProduce.GenerateMode("", strNameSpace);
            }
            catch (Exception ex)
            {
                result.Add(ex.Message);
            }

            return Json(result);
        }
        public ActionResult CreateBussiness(string strNameSpace)
        {

            List<string> result = new List<string>();
            try
            {
                result = CodeProduce.GenerateBussiness("", strNameSpace);
            }
            catch (Exception ex)
            {
                result.Add(ex.Message);
            }

            return Json(result);
        }
        public ActionResult CreateDBAccess(string strNameSpace)
        {

            List<string> result = new List<string>();
            try
            {
                result = CodeProduce.GenerateDBAccess("", strNameSpace);
            }
            catch (Exception ex)
            {
                result.Add(ex.Message);
            }

            return Json(result);
        }
    }
}
